package cn.jbolt.core.poi.excel;

import org.apache.poi.ss.usermodel.CellStyle;

/**
 * jboltexcel中使用模板填充用的数据 根据坐标定位
 *
 * @ClassName: JBoltExcelTplData
 * @author: JFinal学院-小木 QQ：909854136
 * @date: 2020年11月5日
 */
public class JBoltExcelPositionData {
	private int row;
	private int col;
	private int lastRow;
	private int lastCol;
	private Object value;
	private CellStyle cellStyle;
	private boolean valueIsFormula;

	private JBoltExcelPositionData(int row, int col, Object value, CellStyle cellStyle, boolean valueIsFormula) {
		this.row = row;
		this.col = col;
		this.value = value;
		this.cellStyle = cellStyle;
		this.valueIsFormula = valueIsFormula;
	}

	private JBoltExcelPositionData(String position, Object value, CellStyle cellStyle, boolean valueIsFormula) {
		int[] pos = JBoltExcelUtil.positionStrSplit(position);
		this.row = pos[0];
		this.col = pos[1];
		this.value = value;
		this.cellStyle = cellStyle;
		this.valueIsFormula = valueIsFormula;
	}

	private JBoltExcelPositionData(String position, String lastPosition, Object value) {
		int[] pos = JBoltExcelUtil.positionStrSplit(position);
		this.row = pos[0];
		this.col = pos[1];
		int[] lastPos = JBoltExcelUtil.positionStrSplit(lastPosition);
		this.lastRow = lastPos[0];
		this.lastCol = lastPos[1];
		this.value = value;
	}

	private JBoltExcelPositionData(int row, int col, Object value) {
		this(row, col, value, false);
	}

	private JBoltExcelPositionData(int row, int col, Object value, boolean valueIsFormula) {
		this(row, col, value, null, valueIsFormula);
	}

	private JBoltExcelPositionData(int row, int col, Object value, CellStyle cellStyle) {
		this(row, col, value, cellStyle, false);
	}

	private JBoltExcelPositionData(int row, String colStr, Object value) {
		this(row, colStr, value, null);
	}

	private JBoltExcelPositionData(int row, String colStr, Object value, CellStyle cellStyle) {
		this(row, colStr, value, cellStyle, false);
	}

	private JBoltExcelPositionData(int row, String colStr, Object value, CellStyle cellStyle, boolean valueIsFormula) {
		this(row, JBoltExcelUtil.colStrToNum(colStr), value, cellStyle, valueIsFormula);
	}

	private JBoltExcelPositionData(int row, String colStr, Object value, boolean valueIsFormula) {
		this(row, JBoltExcelUtil.colStrToNum(colStr), value, null, valueIsFormula);
	}

	private JBoltExcelPositionData(String colStr, int row, Object value) {
		this(colStr, row, value, null);
	}

	private JBoltExcelPositionData(String colStr, int row, Object value, CellStyle cellStyle) {
		this(colStr, row, value, cellStyle, false);
	}

	private JBoltExcelPositionData(String colStr, int row, Object value, CellStyle cellStyle, boolean valueIsFormula) {
		this(row, colStr, value, cellStyle, valueIsFormula);
	}

	private JBoltExcelPositionData(String colStr, int row, Object value, boolean valueIsFormula) {
		this(row, colStr, value, null, valueIsFormula);
	}

	private JBoltExcelPositionData(String position, Object value) {
		this(position, value, null);
	}

	private JBoltExcelPositionData(String position, Object value, CellStyle cellStyle) {
		this(position, value, cellStyle, false);
	}

	private JBoltExcelPositionData(String position, Object value, boolean valueIsFormula) {
		this(position, value, null, valueIsFormula);
	}

	/**
	 * 通过row和col定位单元格设置数据 从1开始
	 *
	 * @param row   行 从1开始
	 * @param col   列 从1开始
	 * @param value
	 * @return
	 */
	public static JBoltExcelPositionData create(int row, int col, Object value) {
		return new JBoltExcelPositionData(row, col, value);
	}

	/**
	 * 通过row和col定位单元格设置数据 从1开始
	 *
	 * @param row       行 从1开始
	 * @param col       列 从1开始
	 * @param value
	 * @param cellStyle
	 * @return
	 */
	public static JBoltExcelPositionData create(int row, int col, Object value, CellStyle cellStyle) {
		return new JBoltExcelPositionData(row, col, value, cellStyle);
	}

	/**
	 * 通过row和col定位单元格设置数据 从1开始
	 *
	 * @param row            行 从1开始
	 * @param col            列 从1开始
	 * @param value
	 * @param valueIsFormula
	 * @return
	 */
	public static JBoltExcelPositionData create(int row, int col, Object value, boolean valueIsFormula) {
		return new JBoltExcelPositionData(row, col, value, valueIsFormula);
	}

	/**
	 * 通过row和col定位单元格设置数据 从1开始
	 *
	 * @param row            行 从1开始
	 * @param col            列 从1开始
	 * @param value
	 * @param cellStyle
	 * @param valueIsFormula
	 * @return
	 */
	public static JBoltExcelPositionData create(int row, int col, Object value, CellStyle cellStyle,
			boolean valueIsFormula) {
		return new JBoltExcelPositionData(row, col, value, cellStyle, valueIsFormula);
	}

	/**
	 * 定位列用字符串 例如 create(5,"E","值")
	 *
	 * @param row    行 从1开始
	 * @param colStr 列字符串
	 * @param value
	 * @return
	 */
	public static JBoltExcelPositionData create(int row, String colStr, Object value) {
		return new JBoltExcelPositionData(row, colStr, value);
	}

	/**
	 * 定位列用字符串 例如 create(5,"E","值",cellStyle)
	 *
	 * @param row       行 从1开始
	 * @param colStr    列字符串
	 * @param value
	 * @param cellStyle
	 * @return
	 */
	public static JBoltExcelPositionData create(int row, String colStr, Object value, CellStyle cellStyle) {
		return new JBoltExcelPositionData(row, colStr, value, cellStyle);
	}

	/**
	 * 定位列用字符串 例如 create(5,"E","值")
	 *
	 * @param row            行 从1开始
	 * @param colStr         列字符串
	 * @param value
	 * @param valueIsFormula
	 * @return
	 */
	public static JBoltExcelPositionData create(int row, String colStr, Object value, boolean valueIsFormula) {
		return new JBoltExcelPositionData(row, colStr, value, valueIsFormula);
	}

	/**
	 * 定位列用字符串 例如 create(5,"E","值",cellStyle,true)
	 *
	 * @param row            行 从1开始
	 * @param colStr         列字符串
	 * @param value
	 * @param cellStyle
	 * @param valueIsFormula
	 * @return
	 */
	public static JBoltExcelPositionData create(int row, String colStr, Object value, CellStyle cellStyle,
			boolean valueIsFormula) {
		return new JBoltExcelPositionData(row, colStr, value, cellStyle, valueIsFormula);
	}

	/**
	 * 定位列用字符串 例如 create("E",5,"值")
	 *
	 * @param colStr 列字符串
	 * @param row    行 从1开始
	 * @param value
	 * @return
	 */
	public static JBoltExcelPositionData create(String colStr, int row, Object value) {
		return new JBoltExcelPositionData(colStr, row, value);
	}

	/**
	 * 定位列用字符串 例如 create("E",5,"值",cellStyle)
	 *
	 * @param colStr 列字符串
	 * @param row    行 从1开始
	 * @param value
	 * @return
	 */
	public static JBoltExcelPositionData create(String colStr, int row, Object value, CellStyle cellStyle) {
		return new JBoltExcelPositionData(colStr, row, value, cellStyle);
	}

	/**
	 * 定位列用字符串 例如 create("E",5,"值")
	 *
	 * @param colStr         列字符串
	 * @param row            行 从1开始
	 * @param value
	 * @param valueIsFormula
	 * @return
	 */
	public static JBoltExcelPositionData create(String colStr, int row, Object value, boolean valueIsFormula) {
		return new JBoltExcelPositionData(colStr, row, value, valueIsFormula);
	}

	/**
	 * 定位列用字符串 例如 create("E",5,"值")
	 *
	 * @param colStr         列字符串
	 * @param row            行 从1开始
	 * @param value
	 * @param cellStyle
	 * @param valueIsFormula
	 * @return
	 */
	public static JBoltExcelPositionData create(String colStr, int row, Object value, CellStyle cellStyle,
			boolean valueIsFormula) {
		return new JBoltExcelPositionData(colStr, row, value, cellStyle, valueIsFormula);
	}

	/**
	 * 定位字符串 例 E5或者E:5 create("E5","值")或者create("E:5","值")
	 *
	 * @param position 定位字符串 E5或者E:5
	 * @param value
	 * @return
	 */
	public static JBoltExcelPositionData create(String position, Object value) {
		return new JBoltExcelPositionData(position, value);
	}

	/**
	 * 定位字符串 例 E5或者E:5 create("E5","值",cellStyle)或者create("E:5","值",cellStyle)
	 *
	 * @param position  定位字符串 E5或者E:5
	 * @param value
	 * @param cellStyle
	 * @return
	 */
	public static JBoltExcelPositionData create(String position, Object value, CellStyle cellStyle) {
		return new JBoltExcelPositionData(position, value, cellStyle);
	}

	/**
	 * 定位字符串 例 E5或者E:5 create("E5","值")或者create("E:5","值")
	 *
	 * @param position       定位字符串 E5或者E:5
	 * @param value
	 * @param valueIsFormula
	 * @return
	 */
	public static JBoltExcelPositionData create(String position, Object value, boolean valueIsFormula) {
		return new JBoltExcelPositionData(position, value, valueIsFormula);
	}

	/**
	 * 定位字符串 例 E5或者E:5
	 * create("E5","值",cellStyle,true)或者create("E:5","值",cellStyle,true)
	 *
	 * @param position       定位字符串 E5或者E:5
	 * @param value
	 * @param valueIsFormula
	 * @return
	 */
	public static JBoltExcelPositionData create(String position, Object value, CellStyle cellStyle,
			boolean valueIsFormula) {
		return new JBoltExcelPositionData(position, value, cellStyle, valueIsFormula);
	}

	/**
	 * 定位字符串 例 E5或者E:5
	 * create("E5","值",cellStyle,true)或者create("E:5","值",cellStyle,true)
	 *
	 * @param position     定位字符串 E5或者E:5
	 * @param lastPosition 定位字符串 E5或者E:5
	 * @param value
	 * @return
	 */
	public static JBoltExcelPositionData create(String position, String lastPosition, Object value) {
		return new JBoltExcelPositionData(position, lastPosition, value);
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public int getCol() {
		return col;
	}

	public void setCol(int col) {
		this.col = col;
	}

	public boolean isValueIsFormula() {
		return valueIsFormula;
	}

	public void setValueIsFormula(boolean valueIsFormula) {
		this.valueIsFormula = valueIsFormula;
	}

	public CellStyle getCellStyle() {
		return cellStyle;
	}

	public void setCellStyle(CellStyle cellStyle) {
		this.cellStyle = cellStyle;
	}

	public int getLastRow() {
		return lastRow;
	}

	public void setLastRow(int lastRow) {
		this.lastRow = lastRow;
	}

	public int getLastCol() {
		return lastCol;
	}

	public void setLastCol(int lastCol) {
		this.lastCol = lastCol;
	}
}
